<?php
class App_Module_Admin_Component_Articles_Tpl_ThemeList extends App_Module_Admin_Tpl_List
{
	protected $_showCells = array('themetitle', 'icons');
	protected $_emptyListMessage = 'Пока что не выбрана ни одна статья';
	protected $_showEmptyList = true;

    public function GetList($ctrlName, $blog, $entry)
    {
        $this->ctrlName = $ctrlName;
        $this->blog = $blog;
        $this->entry = $entry;

        if (sizeof($entry->GetRelatedEntries()))
        {
        	$objects = Mozg_Mapper::Get('Articles')->GetList(array('ids' => $entry->GetRelatedEntries(), 'blogId' => $blog->GetId()));
        }
        else
        {
        	$objects = array();
        }

        $this->content = $this->CreateList($objects);

        Mozg::SubAction()->Add('RequiredJS', array($this, 'ThemeEntryJS'), array(), 'ThemeEntry');

        return $this->GetTpl('Base')->RightBlock(Mozg_Lang::_('THEME_ARTICLES'), $this->render('articles/_out_theme_block.phtml'));
    }

    public function ThemeEntryJS()
    {
    	return $this->render('articles/js/_themeentry.js');
    }

    public function GetSingleRow($ctrlName, $blog, $entry, $themeEntry)
    {
        $this->ctrlName = $ctrlName;
        $this->blog = $blog;
        $this->entry = $entry;

        return $this->GetRow($themeEntry);
    }

	protected function GetCellThemeTitle($obj)
	{
		$this->obj = $obj;
		return $this->render('articles/themelist/_title.phtml');
	}

	protected function GetCellIcons($obj)
	{
        $icons = array(
        	'delete' => array(
        					'title' => 'Удалить статью из списка?',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=deltheme&blog=' .$this->blog->GetId(). '&main_theme_id=' .$this->entry->GetId(). '&theme_id=' .$obj->GetId())
        					),

        );
		return $this->GetTpl('Icon')->GetIconSet($icons, 'list');
	}
}